<?php

/**
 * WP_Posts_API example usage
 * Using cURL we demostrate a basic way to hit a WP_Posts_API page to query some blog posts.
 * In this example we get all posts in category 1 (usually 'uncategorized').
 *
 * @see http://code.google.com/p/wordpress-posts-api/
 */
/**
 * NOTE: This example will query a blog hosted by me. I am an a very modest hosting package, so please do not abuse.
 */
function sendPost($url, $params, $timeout = 10)
{
	$qs = http_build_query($params);
	$ch = curl_init($url);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $qs);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
	curl_setopt($ch, CURLOPT_REFERER, "http://www.test.com");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
	$data = curl_exec($ch);
	curl_close($ch);
	return $data;
}

$response = sendPost('http://labs.staydecent.ca/wordpress/query/', array('q' => 'cat=1'));
$in = json_decode($response);
print_r($in);

?>